<?php
/*
	Aurus CMS - free OOP CMS
	Copyright (C) 2010  Nestor Yanchuk

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('ROOT')) die();
$PER_PAGE = 25;
$page = isset($_GET['page']) ? toInt($_GET['page']) : 1;

$lim = ($page - 1) * $PER_PAGE . ',' . $PER_PAGE;

$users_q = Mysql::getInstance()->select('users', '*', '', $lim, 'login ASC', '', array(), 1);
$count = Mysql::getInstance()->getarray("SELECT FOUND_ROWS() as count");

$pages = Modules::getInstance()->genNavAsText($page, $PER_PAGE, $count['count'], LINK_ROOT . 'adminarea/?do=users&mod=showall&page=');

$table = Html::tr(Html::td('ID', 'chead', 'left', '2%', 'middle') . Html::td(__('Логін користувача'), 'chead', 'left', '11%', 'middle') . Html::td(__('E-mail адреса'), 'chead', 'left', '15%', 'middle') . Html::td(__('Номер ICQ'), 'chead', 'left', '10%', 'middle') . Html::td(__('Група'), 'chead', 'left', '18%', 'middle') . Html::td(__('Дата реєстрації'), 'chead', 'left', '15%', 'middle') . Html::td(__('Країна'), 'chead', 'left', '14%', 'middle') . Html::td(__('Аватар'), 'chead', 'left', '15%', 'middle'));

foreach ($users_q as $user) {
	$table .= Html::tr(Html::td($user['uid'], 'confclass', 'left', '2%', 'middle') . Html::td('<a href="' . LINK_ROOT . 'adminarea/?do=users&editUser=' . $user['uid'] . '">' . $user['login'] . '</a>', 'confclass', 'left', '11%', 'middle') . Html::td($user['email'], 'confclass', 'left', '15%', 'middle') . Html::td($user['icq'] . '&nbsp', 'confclass', 'left', '10%', 'middle') . Html::td(Users::getInstance()->getGroupData('groupname', $user['group']), 'confclass', 'left', '18%', 'middle') . Html::td(au_date('l, j F Y, G:i', $user['reg_date']), 'confclass', 'left', '15%', 'middle') . Html::td($user['country'] . '&nbsp', 'confclass', 'left', '14%', 'middle') . Html::td(isset($user['avatar']) ? '<img src="' . LINK_ROOT . $user['avatar'] . '" alt="" height="50" />' : Users::getInstance()->noavatar, 'confclass', 'left', '15%', 'middle'));
}

Aurus::getInstance()->addContent($pages . '<br />' . Html::table($table) . '<br />' . $pages);